<script setup lang="ts">
import {webInfoStore} from "@/store";
import {onMounted,ref} from "vue";
import SvgIcon from "@/components/common/SvgIcon.vue";
const webInfo = webInfoStore()
const iconList = ref()
onMounted(() => {
  iconList.value = webInfo.getWebLinkInfo
  // iconList.value = JSON.parse(JSON.stringify(webInfo.getWebLinkInfo))
  // console.log('iconList',iconList.value)
  // iconList.value.forEach((item:Link) => {
  //   if(!item.icon.includes('-logo')){
  //     item.icon = `${item.icon}-logo`
  //   }
  // })
})
</script>

<template>
  <div class="webmaster">
    <div class="avatar">
      <img v-lazy="webInfo.getAvatar" alt="">
    </div>
    <div class="name">
      {{ webInfo.getNickname }}
    </div>
    <div class="signature">
      {{ webInfo.getSignature }}
    </div>
    <div class="statistics">
      <div class="column">
        <div>
          <span>文章</span>
          <span>{{ webInfo.statistics.articleCount }}</span>
        </div>
        <div>
          <span>访问量</span>
          <span>{{ webInfo.statistics.visitCount }}</span>
        </div>
      </div>
      <div class="column">
        <div>
          <span>分类</span>
          <span>{{ webInfo.statistics.categoryCount }}</span>
        </div>
        <div>
          <span>评论总数</span>
          <span>{{ webInfo.statistics.commentCount }}</span>
        </div>
      </div>
    </div>
    <div class="social">
      <div class="icon-list">
        <a v-for="item in iconList" :key="item.icon" :href="item.link" target="_blank">
          <SvgIcon class-name="icon" :icon-class="item.icon + '-logo'"/>
        </a>
      </div>
    </div>
  </div>
</template>

<style scoped lang="less">
.webmaster {
  min-width: 300px;
  //min-height: 456px;
  height: 456px;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px;
  //position: relative;
  .avatar {
    width: 118px;
    height: 118px;
    border: 1px solid #999999;
    border-radius: 50%;
    overflow: hidden;
    & > img{
      width: 100%;
      height: 100%;
      object-fit: cover;
    }
  }
  .name {
    margin-top: 12px;
    font-size: 24px;
    font-weight: 500;
    height: 38px;
    text-align: center;
    color: #333333;
  }
  .signature {
    padding: 0 22px;
    margin-top: 8px;
    font-size: 13px;
    text-align: center;
    color: #666666;
  }
  .statistics {
    margin-top: auto;
    //margin-bottom: 25px;
    //margin-top: 15px;
    padding: 0 22px;
    box-sizing: border-box;
    width: 100%;
    display: flex;
    justify-content: space-between;
    .column {
      //display: flex;
      display: grid;
      //flex-wrap: wrap;
      margin-bottom: 10px;
      div {
        //text-align: center;
        font-size: 14px;
        margin-top: 12px;
        span{
          display: block;
          &:first-child {
            color: #999;
          }
          &:last-child {
            color: #333;
            font-weight: 500;
          }
        }
      }
    }
  }
  .social {
    //position: absolute;
    //bottom: 25px;
    //margin-top: auto;
    margin-top: 25px;
    display: flex;
    justify-content: space-around;
    //margin-top: 20px;
    a{
      .icon{
        width: 16px;
        height: 16px;
      }
      &:after{
        content: '';
        display: inline-block;
        width: 1px;
        height: 21px;
        background: rgba(0, 0, 0, 0.14);
        vertical-align: middle;
        margin: 0 16px;
        transform: scaleY(0.5);
        transform-origin: 0 0;
      }
      &:last-child{
        &:after{
          display: none;
        }
      }
    }
  }
}
</style>
